#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <experimental/filesystem>

using namespace std;

int main(int argc, char **argv)
{
    cout << "start" << endl;

    ifstream yaml_file("/home/robot/map/a2022-11-09/a2022-11-09.yaml", ios_base::in);
    ifstream pgm_file("/home/robot/map/a2022-11-09/a2022-11-09.pgm", ios_base::in);




    string inputLine = "";
    stringstream ss;


    std::getline(pgm_file, inputLine);
    std::getline(pgm_file, inputLine);
    std::getline(pgm_file, inputLine);

    ss << inputLine;
    int size_y, size_x;
    ss >> size_y >> size_x;

    cout << inputLine << "|" << size_x << "|" << size_y << endl;

    getline(yaml_file, inputLine);
    getline(yaml_file, inputLine);

    float x, y;
    cout << inputLine << endl;

    x = stof(inputLine.substr(std::string("resolution: ").size()));
    cout << inputLine << " | " << x << endl;
    getline(yaml_file, inputLine);
    inputLine = inputLine.substr(std::string("origin: [").size());
    inputLine = inputLine.substr(0, inputLine.find_last_of(','));
    x         = stof(inputLine.substr(0,inputLine.find_first_of(',')));
    y         = stof(inputLine.substr(inputLine.find_first_of(',')+1));
    cout << inputLine << "|" << x << "|" << y << endl;

    return 0;
}
